import {useState, useEffect} from 'react'
const Hooks = () => {
    const [count, setCount] = useState(0);
    const [list, setList] = useState([1,2]);
    const add = ()=>{
        setCount(count+1);
    }
    const add2 = ()=>{
        setList([...list,Math.random()]);
    }
    return (
        <div>
            <h1>Hooks</h1>
            <ul>
                {
                    list.map(item=>{
                        return <li key={item}>{item}</li>
                    })
                }
            </ul>
            <button onClick={add2}>添加</button>
            <h2>{count}</h2>
            <button onClick={add}>点击 +1</button>
        </div>
    )
}

export default Hooks